var LRU = require("lru-cache")
    , options = {
        max: 10000 //缓存队列长度10000条
        , length: function (n, key) { return n * 2 + key.length }
        , dispose: function (key, n) { n = '' }
        , maxAge: 24 * 60 * 60 * 1000// 缓存有效期1天
    }
    , lruCache = new LRU(options);

function set(key, value) {
    if (value) {
        lruCache.set(key, JSON.stringify(value))
        return true
    }
    return false
}

function get(key) {
    let result = lruCache.get(key)
    if (result) {
        return JSON.parse(result)
    }
    return null
}

function del(key) {
    lruCache.del(key)
}

module.exports = {
    set,
    get,
    del
}